<?php

$sql = "select * from matchs where status<2";
$matchs=db_fetch_all($sql);
foreach($matchs as $match)
{
	$now = convertTimeToLocal( date("Y-m-d H:i:s") , date("O")/100 );	
	$difference = strtotime(convertTimeToLocal($match->kick_off,$match->timezone)) - strtotime($now); 
	$minremain =  round($difference/60);
	
	if($minremain <= -150)
	{
		$data["status"] = 2;	//end	
		db_update("matchs",$match->id,$data);
	}		
	else if($minremain <= 5)
	{
		$data["status"] = 1;	//now playing	
		db_update("matchs",$match->id,$data);
	}	
		
}
?>